package cc.flybb.sharedpreferences2;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.util.Log;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

//        SharedPreferences shp = getSharedPreferences("hello", Context.MODE_PRIVATE);
//        SharedPreferences.Editor editor = shp.edit();
//        editor.putInt("NUMBER",100);
//        //editor.apply();//据说这个是异步的可以避免冲突
//        editor.commit();
//
//        int x = shp.getInt("NUMBER",0);
//        String TAG = "myLog";
//        Log.d(TAG,"onCreate "+x);

        MyData myData = new MyData(getApplicationContext());
        myData.number = 1000;
        myData.save();
        int y = myData.load();
        String TAG = "myLog";
        Log.d(TAG,"onCreate"+y);
    }
}